import { getToken, removeToken, setToken } from "@/utils/storage";

/**
 *
 * @type {import('vuex').module}
 */
const user = {
  namespaced: true,
  state: {
    token: getToken(),
  },
  mutations: {
    setToken(state, newToken) {
      setToken(newToken);
      state.token = newToken;
    },
    delToken(state) {
      removeToken();
      state.token = null;
    },
  },
};

export default user;
